<template>
  <div class>
      <el-card class="ep-card ep-search">
          <el-row :gutter="0">
            <el-col :span="2" style="float:right">
              <el-button type="success"  @click="save">保存</el-button>
            </el-col>
          </el-row>
        </el-card>
    <el-tabs type="border-card">
      <el-tab-pane label="项目概况">
        <ManagementoneComponent ref="ManagementoneComponent"></ManagementoneComponent>
      </el-tab-pane>
      <el-tab-pane label="股权信息">
        <ManagementtwoComponent ref="ManagementtwoComponent"></ManagementtwoComponent>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  components: {
    ManagementoneComponent: require("./Management-one.vue").default,
    ManagementtwoComponent: require("./Management-two.vue").default
  },
  data() {
    return {
     projId:'',
     busCondEnterId:'',
    };
  },
  computed: {},
  mounted() {
 
  },
  methods: {
    init(projId){
      this.projId=projId;
      //查询
      this.$api.formPost( 'biz/projDataRecentYear/selectProjManagement',{
        projId:projId
      }).then(res => {
                  if(res.retHead.code=="0000000"){
                      if(res.retBody.busCondEnter){
                        this.busCondEnterId=res.retBody.busCondEnter.id;
                        this.$refs.ManagementoneComponent.formData=res.retBody.busCondEnter;
                        this.$refs.ManagementoneComponent.tableData=res.retBody.dataRecentYearList;
                        this.$refs.ManagementtwoComponent.formData=res.retBody.descCurrentBank;
                        this.$refs.ManagementtwoComponent.tableData=res.retBody.currentBankList;
                      }
                    }else{
                        this.$message({
                            type: 'error',
                            message: res.retHead.message
                        });
                    }
       });
    },
    save(){
      let user=JSON.parse(sessionStorage.getItem("user"));
      //主营业务情况
      let busCondEnter = this.$refs.ManagementoneComponent.getFormData();
      //近年经营情况
      let dataRecentYearList= this.$refs.ManagementoneComponent.getTableData();
      //现有银行借款情况
      let currentBankList = this.$refs.ManagementtwoComponent.getTableData();
      //现有银行借款情况说明
      let descCurrentBank = this.$refs.ManagementtwoComponent.getFormData();
      let params={
        createUserId:user.id,
        createUserName:user.realName,
        projId:this.projId,
        busCondEnter:busCondEnter,
        dataRecentYearList:dataRecentYearList,
        currentBankList:currentBankList,
        descCurrentBank:descCurrentBank,
      }
      if(!this.busCondEnterId){
            this.$api.post( 'biz/projDataRecentYear/doSaveManagement',params).then(res => {
            if(res.retHead.code=="0000000"){
              this.$message({
                type: 'success',
                message: "保存成功"
              });
              this.$emit("hiddenComponent");
            }else{
              this.$message({
                type: 'error',
                message: res.retHead.message
              });
            }
          });
      }else{
        this.$api.post( 'biz/projDataRecentYear/doUpdateManagement',params).then(res => {
            if(res.retHead.code=="0000000"){
              this.$message({
                type: 'success',
                message: "更新成功"
              });
              this.$emit("hiddenComponent");
            }else{
              this.$message({
                type: 'error',
                message: res.retHead.message
              });
            }
          });
      }
      
    }

  },
};
</script>
<style lang='scss' scoped>

</style>